import 'package:flutter/cupertino.dart';
import 'package:imember/UI/Pay/Remarks/InputFanDian.dart';
import 'package:imember/UI/Pay/Remarks/InputJC_or_MT.dart';
import 'package:imember/UI/Pay/Remarks/InputZhaiPei.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyDialog.dart';

class Remarks extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _Remarks();
  }
}

class _Remarks extends State {
  static const int JiChange = 0;
  static const int MaTou = 1;
  static const int FanDian = 2;
  static const int ZhaiPei = 3;
  int currentType = -1;

  switchTypeClick(int type) {
    if (currentType != type) {
      showBtn2Dialog(context, "請問是否要更換配送方式?", "取消", () {}, "確認", () {
        setState(() {
          currentType = type;
          switchType(type);
        });
      });
    }
  }

  switchType(int type) {
    if (type == JiChange) {
      showWidgetDialog(context, InputJC_or_MT(JiChange));
    }
    if (type == MaTou) {
      showWidgetDialog(context, InputJC_or_MT(MaTou));
    }
    if (type == FanDian) {
      showWidgetDialog(context, InputFanDian());
    }
    if (type == ZhaiPei) {
      showWidgetDialog(context, InputZhaiPei());
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.only(top: 18),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Button("機場", fontSize: 20, height: 54, width: 91, bgColor: currentType == JiChange ? MyColor.Orange : MyColor.C99, onTap: () {
              switchTypeClick(JiChange);
            }),
            Button("碼頭", fontSize: 20, height: 54, width: 91, bgColor: currentType == MaTou ? MyColor.Orange : MyColor.C99, onTap: () {
              switchTypeClick(MaTou);
            }),
            Button("飯店", fontSize: 20, height: 54, width: 91, bgColor: currentType == FanDian ? MyColor.Orange : MyColor.C99, onTap: () {
              switchTypeClick(FanDian);
            }),
            Button("宅配", fontSize: 20, height: 54, width: 91, bgColor: currentType == ZhaiPei ? MyColor.Orange : MyColor.C99, onTap: () {
              switchTypeClick(ZhaiPei);
            }),
          ],
        ));
  }
}
